package com.control.servlet;

import com.dao.BlogDao;
import com.dao.UserDao;
import com.model.Blog;
import com.model.User;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2017/5/11.
 */
public class UserListServlet extends HttpServlet {
    //这里调用的
    UserDao userDao = new UserDao();

    @Override
    public void init() throws ServletException {
        super.init();
//        blogDao = new BlogDao();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //这里是博客请求的入口。 /blogs.do
        System.out.print("123");
        List<User> users = userDao.getAllUsers();
        req.setAttribute("users", users);

        //这里跳转到一个jsp的界面
        RequestDispatcher dispatcher = req.getRequestDispatcher("/jsp/UserList.jsp");
        dispatcher.forward(req, resp);
    }
}
